package fachada;

import java.awt.Color;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JMenu;
import javax.swing.text.DefaultStyledDocument;

import view.BuscaPeUI;
import view.MenuDemo;
import view.MyPanel;
import view.MyTextPane;
import view.TextFields;
import model.Patente;


/**
 * BuscapeFachada
 * @author Adriano de Albuquerque Batista
 * @author Alfeu Buriti
 * @author Pablo Diego Alencar
 * @author Yuri Cariry Cabral de Melo
 *
 */
public class BuscapeFachada {
	
	private static BuscaPeUI  buscapeUI;
	private static Patente    patente;  
	private static MyTextPane myTextPane;
	private static TextFields textFields;
	private static MyPanel	  myPanel;
	private static MenuDemo	  menuDemo;
	

	/////////////// CONSTRUTORES ////////////////////////////////////////	
	/**
	 * criarBuscaPeUI
	 * @return buscapeUI
	 */
	public BuscaPeUI criarBuscaPeUI(){
		return buscapeUI = new BuscaPeUI();
	}
	
	/**
	 * criarMyTextPane
	 * @return myTextPane
	 */
	public MyTextPane criarMyTextPane(){
		return myTextPane = new MyTextPane(new DefaultStyledDocument());
	}
	
	/**
	 * criarTextFields
	 * @param bp
	 * @return textFields
	 */
	public TextFields criarTextFields(BuscaPeUI bp) {
		return textFields = new TextFields(bp);
	}
	/**
	 * criarMyPanel
	 * @param bp
	 * @return myPanel
	 */
	public MyPanel criarMyPanel(BuscaPeUI bp) {
		return myPanel = new MyPanel(bp);
	}
	/**
	 * criarMenuDemo
	 * @param bp
	 * @return menuDemo
	 */
	public MenuDemo criarMenuDemo(BuscaPeUI bp) {
		return menuDemo = new MenuDemo(bp);
	}
	
	
	
	
	
	
	
	/**
	 * criarPatente
	 * @param title
	 * @param absTract
	 * @param description
	 * @param claims
	 * @return patente
	 */
	public Patente criarPatente(String title, String absTract, String description, String claims){		
		return patente = new Patente ( title,  absTract,  description,  claims);		
	}
	public Patente criarPatente(){		
		return patente = new Patente ();		
	}
	
	
	
	
	
	
	
	
	//////////////////FACHADA MYTEXTPANE//////////////////////////////////////////////


	public void selectWords(){
		 myTextPane.selectWords();
	}
	
	public void findWord (String splitWd){
		 myTextPane.findWord(splitWd);
	}
	public void previousWord(){
		 myTextPane.previousWord();
	}
	public void nextWord(){
		 myTextPane.nextWord();
	}
	
	public  void sendTextToPane(String s) {
		 myTextPane.sendTextToPane(s);
	}
	public  void sendSelecTextToPane(String s) {
		myTextPane.sendSelecTextToPane(s);
	}
	public Insets setMargin(int top, int left, int bottom, int right ){
		return myTextPane.setMargin( top,  left,  bottom,  right );
	}
	///////////////////////////////////////////////////////////////////////////
	
	/////////////// FACHADA TEXT FIELDS ///////////////////////////////////////
	public void actionPerformed(ActionEvent e) {
		textFields.actionPerformed(e);
	}
	public String getEPOResults(String urlLink, String patnum) {
		return textFields.getEPOResults( urlLink,  patnum);
	}
	public void getEPOfigure(String patnum) {
		textFields.getEPOfigure(patnum);
	}
	public void atualizaHistory(String patnum) {
		textFields.atualizaHistory( patnum);
	}
	public void outputText(String s) {
		textFields.outputText(s);
	}
	public void getUSDocument(Patente patente) {
		textFields.getUSDocument(patente);
	}
	public void getSoapRequest(String action, String patnum) {
		textFields.getSoapRequest(action, patnum);
	}
	public void retrieveSoapDocument(String patnum) {
		textFields.retrieveSoapDocument(patnum);
	}
	public void getOPSDocuments(String patnum) {
		textFields.getOPSDocuments(patnum);
	}
	///////////////////////////////////////////////////////////////////////////
	
	
	
	
	///////////////// FACHADA MYPANEL /////////////////////////////////////////
	public JButton newButton(String label, Color color, String actionCommand){
		return myPanel.newButton(label, color, actionCommand);
	}
	public void actionPerformedMyPanel(ActionEvent e) {
		myPanel.actionPerformed(e);
	}
		
		
		
	//////////////////////////////////////////////////////////////////////////
	
	///////////////// FACHADA MENU DEMO /////////////////////////////////////////
	public static void addMenuItem(JMenu menu, String item, char mnemonic,
			String keystroke, ActionListener handler) {
		menuDemo.addMenuItem(menu, item, mnemonic, keystroke, handler);
	}
//	public ActionListener listener = new ActionListener() {	
//		public void actionPerformed(ActionEvent evt) {
//			menuDemo.actionPerformed(evt);
//		} 
//		return menuDemo.listener();
//	}
	
	public void doSave() {
		menuDemo.doSave();
	}
	public void doOpen() {
		menuDemo.doOpen();
	}
	public void doExportXML() {
		menuDemo.doExportXML();
	}
	public void doImportXML() {
		menuDemo.doImportXML();
	}
	//////////////////////////////////////////////////////////////////////////
	
	
		
	/////////////////FACHADA DA PATENTE//////////////////////////////////////////
	
	public String getElementByName(String xml, String tag) {
		return patente.getElementByName( xml,  tag);
	}
	public void exportXML(String pathname, Patente patente) {	
		patente.exportXML( pathname,  patente);
	}
	
	public void geraPatente(Patente patente) {
		patente.geraPatente(patente);
	}
	
	// GETS E SETS
	public String getTitle() {
		return patente.getTitle();
	}
	public void setTitle(String title) {
		patente.setTitle(title);
	}
	
	public String getAbsTract() {
		return patente.getAbsTract();
	}

	public void setAbsTract(String absTract) {
		patente.setAbsTract(absTract);
	}

	public String getDescription() {
		return patente.getDescription();
	}

	public void setDescription(String description) {
		patente.setDescription(description);
	}
	
	public String getClaims() {
		return patente.getClaims();
	}

	public void setClaims(String claims) {
		patente.setClaims(claims);
	}
	public String getPatNum() {
		return patente.getPatNum();
	}

	public void setPatNum(String patNum) {
		patente.setPatNum(patNum);
	}
	public String getPd() {
		return patente.getPd();
	}
	public void setPd(String pd) {
		patente.setPd(pd);
	}	
	public String getInventor() {
		return patente.getInventor();
	}	
	public void setInventor(String inventor) {
		patente.setInventor(inventor);
	}

	public String getApplicant() {
		return patente.getApplicant();
	}
	public void setApplicant(String applicant) {
		patente.setApplicant(applicant);
	}
	public String getIpc() {
		return patente.getIpc();
	}
	public void setIpc(String ipc) {
		patente.setIpc(ipc);
	}

	public String getApplication() {
		return patente.getApplication();
	}
	public void setApplication(String application) {
		patente.setApplication(application);
	}	
	public String getPriority() {
		return patente.getPriority();
	}	
	public void setPriority(String priority) {
		patente.setPriority(priority);
	}

	public String getFamily() {
		return patente.getFamily();
	}	
	public void setFamily(String family) {
		patente.setFamily(family);
	}
	public String getFamilia() {
		return patente.getFamilia();
	}
	public void setFamilia(String familia) {
		patente.setFamilia(familia);
	}
	public String getCited() {
		return patente.getCited();
	}
	public void setCited(String cited) {
		patente.setCited(cited);
	}	
	public String getCiting() {
		return patente.getCiting();
	}
	public void setCiting(String citing) {
		patente.setCiting(citing);
	}
	public String getResumo() {
		return patente.getResumo();
	}
	public void setResumo(String resumo) {
		patente.setResumo(resumo);
	}
	public String getFigura() {
		return patente.getFigura();
	}

	public void setFigura(String figura) {
		patente.setFigura(figura);
	}
	////////////////////////////////////////////////////////////////////////////////
	
	
	
	
	
	
	
	
}
